﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuanLyNhaHang.GUI
{
    public partial class Order : Form
    {
        Bussiness.BusOrder busOrder;
        
        public Order()
        {
            InitializeComponent();
        }

        private void Order_Load(object sender, EventArgs e)
        {
            busOrder = new Bussiness.BusOrder(this);
            //Load Table Table
            busOrder.loadListTable();
            //Load table TD.
            busOrder.loadListTDon();
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
        }

        private void listViewTable_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                Point pos = new Point(e.X, e.Y);
                ListViewHitTestInfo info = listViewTable.HitTest(pos);
                if (info.Item != null && this.listViewTable.SelectedItems.Count > 0
                    & this.listViewTable.SelectedItems.Contains(info.Item))
                {
                    contextMenuStrip1.Show(PointToScreen(pos));
                }

            }
        }

        private void quảnLýKhuVựcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            showAnything("location");
        }

        private void btnMngLocation_Click(object sender, EventArgs e)
        {
            showAnything("location");
        }

        public void showAnything(String nameClass)
        {
            if (nameClass == "location")
            {
                GUI.OrderOption.LocationMng location = new OrderOption.LocationMng(this);
                location.Show();
            }
            else if (nameClass == "transfer")
            {
                GUI.OrderOption.Transfer transfer = new OrderOption.Transfer();
                transfer.Show();
            }
            else if (nameClass == "mas")
            {
                GUI.OrderOption.MergeAndSplit masplit = new GUI.OrderOption.MergeAndSplit();
                masplit.Show();
            }
            else if (nameClass == "nt")
            {
                GUI.OrderOption.NewTable ntable = new OrderOption.NewTable(busOrder.getLocationForNewTable(),this);
                ntable.Show();
            }
            else if (nameClass == "dtable")
            {
                String s = listViewTable.SelectedItems[0].Text.ToString();
            //    MessageBox.Show("Test"+s);
                busOrder.deleteTable(s);
            }

        }

        public void loadLeftTable()
        {
            busOrder.loadListTable();
        }

        private void chuyểnBànToolStripMenuItem_Click(object sender, EventArgs e)
        {
            showAnything("transfer");
        }

        private void táchGộpBànToolStripMenuItem_Click(object sender, EventArgs e)
        {
            showAnything("mas");
        }

        private void thêmMớiBànToolStripMenuItem_Click(object sender, EventArgs e)
        {
            showAnything("nt");
        }

        private void xóaBànToolStripMenuItem_Click(object sender, EventArgs e)
        {
            showAnything("dtable");
        }

        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            GUI.Main main = new Main();
            main.showNotificationMain("hello");
        }


    }
}
